
#include<string.h>
#include<unistd.h>
#include<stdio.h>
#include"processBar.h"
const char *lable = "|/-\\";

char bar[NUM];
void processbar(int rate)
{
    if(rate<0||rate>100) return;
    int len = strlen(lable);
    printf("[%-100s][%d%%][%c]\r",bar,rate,lable[rate%len]);
    fflush(stdout);
    bar[rate++] = BODY;
    if(rate<TOP) bar[rate] = RIGHT;
}

//void processbar(int speed)
//{
//   int cut = 0;
//   char bar[NUM];
//   memset(bar,'\0',sizeof(bar));
//    int len = strlen(lable);
//   while(cut <= TOP)
//   {
//        printf("[%-100s][%d%%][%c]\r",bar,cut,lable[cut%len]);
//        fflush(stdout);
//        bar[cut++] = BODY;
//        if(cut<TOP) bar[cut] = RIGHT;
//        usleep(speed);
//   }
//   printf("\n");
//}
